<template>
<h1>猜数字练习</h1>
  <input type="text" placeholder="请输入你猜的数字" v-model="num">
  <button @click="cyc">猜一猜</button>
  <h3>{{msg}}</h3>
</template>

<script setup>
import {ref} from "vue";
var firstnum = parseInt(Math.random()*100+1);

alert(firstnum);
const num= ref('');
const msg= ref('');
const cyc=()=>{
  if(num.value>firstnum){
    msg.value="猜大了";
  }else if (num.value<firstnum){
    msg.value="猜小了";
  }else {
    msg.value="恭喜你猜对了";
  }
}
</script>

<style scoped>

</style>